package design.patterns.create.singleton;

/**
 * 线程安全，使用双重校验的懒汉单例模式
 */
public class SingletonSafe {
    private SingletonSafe(){}

    private volatile static  SingletonSafe singletonSafe;

    public static SingletonSafe getInstance(){
        if(singletonSafe == null){
            synchronized (SingletonSafe.class){
                if(singletonSafe == null){
                    singletonSafe = new SingletonSafe();
                }
            }
        }

        return singletonSafe;
    }

}
